// uno.config.ts
import {
  defineConfig,
  presetAttributify,
  presetTypography,
  presetWebFonts,
  transformerDirectives,
  transformerVariantGroup,
} from 'unocss';
import presetLegacyCompat from '@unocss/preset-legacy-compat';
import transformerAttributifyJsx from '@unocss/transformer-attributify-jsx';
import presetMini from '@unocss/preset-mini';

export default defineConfig({
  shortcuts: [
    ['flex-y-center', 'flex items-center'],
    ['flex-x-center', 'flex justify-center'],
    ['flex-center', 'flex flex-col justify-center items-center'],
    ['flex-y-between', 'flex items-between'],
    ['flex-x-between', 'flex justify-between'],
    ['flex-between', 'flex justify-between items-between'],
    [
      'hover-icon',
      'flex items-center justify-center hover:bg-blue-500 hover:rounded-full cursor-pointer transition-all duration-300 ease-in-out dark:hover:bg-blue-700 dark:hover:text-white',
    ],
    [
      'flex-page-layout',
      'flex flex-col justify-between items-center h-full w-full overflow-hidden p-2',
    ],
  ],

  presets: [
    // 原 presetUno 已弃用，使用 @unocss/preset-mini 替代
    presetMini(),
    // 支持attributify mode,简单说就是为了避免样式写太长难维护，能将py-2 px-2这种相关属性整合起来写成p="y-2 x-4"
    presetAttributify(),
    presetLegacyCompat({
      // 选项
      commaStyleColorFunction: true,
      legacyColorSpace: true,
    }),
    // 预设字体
    presetTypography(),
    // 预设网络字体
    presetWebFonts(),
  ],
  transformers: [
    // 将JSX转换为属性形式
    transformerAttributifyJsx(),
    // 处理指令
    transformerDirectives(),
    // 处理变体组
    transformerVariantGroup(),
  ],
});
